package decorator.mydecorator

import decorator.Drink

//这个就是装饰者
class Decorator extends Drink {
  //被装饰的对象
  private var obj: Drink = null

  def this(ob: Drink) {
    this
    this.obj = ob
  }


  //获取信息时需要递归调用
  override def getDescription(): String = {
    super.getDescription() + "&&" + obj.getDescription()
  }

  //获取价格时,也需要递归调用
  override def cost(): Float = {
    (super.getPrice() + obj.cost()).toFloat
  }
}
